package com.kitty.web.controller;

import com.kitty.web.controller.BaseController;
import com.kitty.web.common.AjaxResult;
import com.kitty.web.core.page.TableDataInfo;
import com.kitty.web.domain.PBosscount;
import com.kitty.web.service.IPBosscountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * 挑战次数Controller
 * 
 * @author soul
 * @date 2022-03-19
 */
@Controller
@RequestMapping("/system/bosscount")
public class PBosscountController extends BaseController
{
    private String prefix = "system/bosscount";

    @Autowired
    private IPBosscountService pBosscountService;


    @GetMapping()
    public String bosscount()
    {
        return prefix + "/bosscount";
    }

    /**
     * 查询挑战次数列表
     */

    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(PBosscount pBosscount)
    {
        startPage();
        List<PBosscount> list = pBosscountService.selectPBosscountList(pBosscount);
        return getDataTable(list);
    }


    /**
     * 新增挑战次数
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存挑战次数
     */

    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(PBosscount pBosscount)
    {
        return toAjax(pBosscountService.insertPBosscount(pBosscount));
    }

    /**
     * 修改挑战次数
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        PBosscount pBosscount = pBosscountService.selectPBosscountById(id);
        mmap.put("pBosscount", pBosscount);
        return prefix + "/edit";
    }

    /**
     * 修改保存挑战次数
     */

    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(PBosscount pBosscount)
    {
        return toAjax(pBosscountService.updatePBosscount(pBosscount));
    }

    /**
     * 删除挑战次数
     */

    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(pBosscountService.deletePBosscountByIds(ids));
    }
}
